#include <libavformat/avformat.h>
#include <unistd.h>

int main(int argc, char const *argv[])
{
    int ret;
    uint8_t buf[1024];

    AVInputFormat *in_fmt = av_find_input_format("h264");

    AVFormatContext *in_ctx = NULL;

    AVDictionary *opts = NULL;
    av_dict_set(&opts, "listen", "2", 0);

    // avformat_open_input(&in_ctx, "rtmp://0.0.0.0:1935/stream/live", in_fmt, &opts);
    avformat_open_input(&in_ctx, "tcp://0.0.0.0:1935", in_fmt, &opts);

    av_dump_format(in_ctx, 0, "", 0);

    AVPacket *pkt;

    while (1)
    {
        ret = av_read_frame(in_ctx, pkt);
        if (ret < 0)
        {
            printf("ret %d\n", ret);
        }
    }

    return 0;
}
